package com.fy.fyai.common.result;

import lombok.Data;

@Data
public class R<T> {
    private static final Integer OK_CODE = 200;
    private static final Integer NO_CODE = 400;
    private static final String OK = "请求成功";
    private static final String NO = "请求失败";
    private Integer code;
    private String message;
    private T data;

    public R(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> R<T> ok() {
        return new R<>(OK_CODE , OK, null);
    }

    public static <T> R<T> ok(T data) {
        return new R<>(OK_CODE , OK, data);
    }

    public static <T> R<T> no() {
        return new R<>(NO_CODE , NO, null);
    }

    public static <T> R<T> no(String message) {
        return new R<>(NO_CODE , message, null);
    }
}